#include<iostream>
#include<fstream>
#include<string.h>
#include<iomanip>
using namespace std;
#define MAXSIZE 100
#define ERROR -1
#define OK 1
typedef struct{
    int id;
    char name[20];
    double g1, g2;
}student;
typedef struct{
    student *elem;
    int length;
}SeqList;
int Show_List(SeqList L)
{
    cout << "学号" << "  " << "姓名" << "    " << "成绩1" << "    " << "成绩2" << endl;    
    for(int i = 0; i < L.length; i++)
    {
        cout << setfill(' ') << setw(4) << setiosflags(ios::left) << L.elem[i].id << "  "
        << setfill(' ') << setw(10) << setiosflags(ios::left) << L.elem[i].name
        << setfill(' ') << setw(10) << setiosflags(ios::left)
        << L.elem[i].g1 << setfill(' ') << setw(10) << setiosflags(ios::left) << L.elem[i].g2 << endl;
    }
    return OK;
}
int main()
{
    SeqList L;
    ifstream infile;
    infile.open("D:\\MinGW\\a.txt", ios::in);
    if(!infile)
    {
        cout << "打开失败" << endl;
        return ERROR;
    }
    L.elem = new student[MAXSIZE];
    L.length = 0;
    for(int i = 0; i < MAXSIZE; i++)
    {
        if(infile >> L.elem[i].id && infile >> L.elem[i].name && infile >> L.elem[i].g1 && infile >> L.elem[i].g2)
        {
            L.length++;
        }
        else
        {
            break;
        }
    }
    Show_List(L); 
    infile.close();
    delete[] L.elem; // 释放内存
    return 0;
}